<template>
	<view class="cart-settle">
		<label class="radio" @click="radioClickHandler">
			<radio color="#c00000" :checked="isAllSelect"/><text>全选</text>
		</label>
		<view>
			合计:<text class="amount-box">￥{{selectGoodsPrice}}</text>
		</view>
		<view class="btn-settle">
			结算({{selectGoodsCount}})
		</view>
	</view>
</template>

<script>
	import { mapGetters, mapMutations } from "vuex";
	export default {
		name: "cart-settle",
		data() {
			return {
			};
		},
		methods:{
			//使用 mapMutations 辅助函数，把 m_cart 模块提供的 updateAllGoodsState 方法映射到当前组件中使用
			...mapMutations('m_cart', ['updateAllGoodsState']),
			radioClickHandler(){
				this.updateAllGoodsState(!this.isAllSelect)
			}
		},
		computed:{
			...mapGetters('m_cart', ['selectGoodsCount', 'total', 'selectGoodsPrice']),
			isAllSelect(){
				return this.total === this.selectGoodsCount
			}
		}
	}
</script>

<style lang="scss">
	.cart-settle {
		display: flex;
		justify-content: space-between;
		align-items: center;
		position: fixed;
		bottom: 0;
		left: 0;
		z-index: 999;
		height: 50px;
		width: 100%;
		padding-left: 5px;
		box-sizing: border-box;
		background-color: #fff;
		font-size: 14px;
		.radio{
			display: flex;
			align-items: center;
		}
		.amount-box{
			color: #c00000;
		}
		.btn-settle {
			height: 50px;
			min-width: 100px;
			background-color: #c00000;
			color: white;
			text-align: center;
			line-height: 50px;
		}
	}
</style>